#ifndef DATAOBJECT_H
#define DATAOBJECT_H

#include <QObject>
#include <QString>

class DataObject : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
    Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)

public:
    DataObject(const QString& name, const QString& color, QObject* parent = nullptr)
        : QObject{parent}, m_name(name), m_color(color)
    { }

    QString name() {
        return m_name;
    }
    void setName(const QString& name) {
        QString oldName = m_name;
        m_name = name;
        if (oldName != m_name)
            emit nameChanged(oldName);
    }

    QString color() {
        return m_color;
    }

    void setColor(const QString& color) {
        QString oldColor = m_color;
        m_color = color;
        if (oldColor != color) {
            emit colorChanged(oldColor);
        }
    }

signals:
    void nameChanged(QString oldValue);
    void colorChanged(QString oldValue);

private:
    QString m_name;
    QString m_color;
};

#endif // DATAOBJECT_H
